<include file="./Template/Admin/header.html" title="修改密码" />
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改密码</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="editForm" action="{:U('Admin/Login/pwdSave')}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">用户名:</label>
                            <div class="col-sm-8">
                                <label>{$_SESSION['user']['name']}</label>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">原密码:</label>
                            <div class="col-sm-8">
                                <input id="oldpwd" name="oldpwd" class="form-control" type="password">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">新密码:</label>
                            <div class="col-sm-8">
                                <input id="newpwd" name="newpwd" class="form-control" type="password">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">确认新密码:</label>
                            <div class="col-sm-8">
                                <input id="confirm_pwd" name="confirm_pwd" class="form-control" type="password">
                                <span class="help-block m-b-none"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">提交</button>
                                <button class="btn btn-white" type="reset"  onclick="history.go(-1)">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__ADMIN__js/jquery.min.js"></script>
<script src="__ADMIN__js/bootstrap.min.js"></script>
<script src="__ADMIN__js/plugins/layer.3/layer.js"></script>
<script src="__ADMIN__js/common.js"></script>
<script src="__ADMIN__js/content.min.js"></script>
<script src="__ADMIN__js/plugins/validate/jquery.validate.min.js"></script>
<script src="__ADMIN__js/plugins/validate/messages_zh.min.js"></script>
<script>
    $(function(){
        $.validator.setDefaults({
            highlight: function (e) {
                $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
            }, success: function (e) {
                e.closest(".form-group").removeClass("has-error").addClass("has-success")
            }, errorElement: "span", errorPlacement: function (e, r) {
                e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
            }, errorClass: "help-block m-b-none", validClass: "help-block m-b-none"
        });
        $().ready(function () {
            var e = "<i class='fa fa-times-circle'></i> ";

            $("#editForm").validate({
                rules: {
                    oldpwd: "required",
                    newpwd: {required: true, minlength: 5, maxlength: 15},
                    confirm_pwd: {required: true, minlength: 5, maxlength: 15, equalTo: "#newpwd"}
                },
                messages: {
                    oldpwd: {required: e + "请输入您的原密码"},
                    newpwd: {required: e + "请输入您的新密码", minlength: e + "密码必须5个字符以上", maxlength: e + "密码必须小于15个字符"},
                    confirm_pwd: {required: e + "请再次输入新密码", minlength: e + "密码必须5个字符以上", maxlength: e + "密码必须小于15个字符", equalTo: e + "两次输入的密码不一致"}
                },
                submitHandler: function(form){
                    var data = new  FormData(document.getElementById('editForm'));
                    $.ajax({
                        url:$(form).attr('action'),
                        type:"POST",
                        data:data,
                        cache: false,
                        processData:false,
                        contentType:false,
                        success:function(data){
                            if(data.status > 0){
                                common.error(data.msg);
                            }else{
                                common.success(data.msg,"{:U('Admin/Login/editPwd')}");
                            }
                        },
                        dataType:'JSON'
                    });
                    return false;
                }
            });
        });

    });
</script>
</body>
</html>
